<?php

class UserAddressCsv{
	
	//原生数据
	private $data = array();
	//每一行
	private $lines = array();
	
	private $data_list = array();
	
	//每一行
	private $line_count = 0;
	
	function __construct(){
		
	}
	
	//数组转
	function array_to_data($array){
		
		$this->data = $array;
		$this->line_count = count($this->data);

		$keys = array(
			'user_id',
			'consignee',
			'address' ,
			'mobile_phone'
		);
		
		
		foreach($this->data as $i => $d){
			//合并
			
			//默认客户为0
			array_unshift($d, 0);
			$this->lines[] = array_combine($keys, $d);
		}
		
		return $this->lines;
	}

	
	
	//数组转
	function update_array_to_data($array){
		
		$this->data = $array;
		$this->line_count = count($this->data);

		$keys = array(
			'id',
			'consignee',
			'address' ,
			'mobile_phone',
			'disabled',
			'last_use_time'
		);
		
		
		foreach($this->data as $i => $d){
			//合并
			$disabled = 1;
			if($d[4] == '启用'){
				$disabled = 0;
			}
			
			$d[4] = $disabled;
			
			$this->lines[] = array_combine($keys, $d);
		}
		
		return $this->lines;
	}
	
	
}

?>